package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.bean.BuildingBean;
import com.sxz.sbs.module.client.view.BuildingView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 获取小区下楼号
 */
public class BuildingPresenter extends RxPresenter<BuildingView>{
    /**
     * 获取楼栋
     * @param map
     */
    public void getBuildingList (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getBuildingList(map)
                .compose(RxUtil.<BuildingBean>handleResult())
                .subscribeWith(new RxSubscriber<BuildingBean>(mView){
                    @Override
                    public void onNext(BuildingBean data) {
                       mView.onClientListSuccess(data);
                    }
                })
        );
    }

    /**
     * 提交确定分配接口
     * @param map
     */
    public void getSubmit (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getSubmit(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onSubmitSuccess(data);
                    }
                })
        );
    }
}
